package com.lemon.boot.controller;

import com.lemon.boot.common.base.BaseController;
import com.lemon.boot.common.utils.JwtUtil;
import com.lemon.boot.dto.RoleDTO;
import com.lemon.boot.po.RolePO;
import com.lemon.boot.service.IRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 角色表控制层
 *
 * @author Lemon
 * @since 2024-02-29
 */
@Log4j2
@Api(tags = "角色管理")
@RestController
@RequestMapping("role")
public class RoleController extends BaseController<RolePO, RoleDTO, IRoleService> {
    /**
     * 根据租户ID查询角色ID，角色名称
     *
     * @return
     */
    @ApiOperation(value = "根据租户ID查询角色ID，角色名称")
    @GetMapping("getByCurrentTenantId")
    public List<RolePO> getByCurrentTenantId(){
        return super.service.getByCurrentTenantId(JwtUtil.getCurrentUser().getTenantId());
    }

    /**
     * 根据租户ID查询普通角色ID，角色名称
     *
     * @return
     */
    @ApiOperation(value = "根据租户ID查询普通角色ID，角色名称")
    @GetMapping("getCommonByCurrentTenantId")
    public List<RolePO> getCommonByCurrentTenantId(){
        return super.service.getCommonByCurrentTenantId();
    }
}